package fr.imag.ufrima.ctte.gui.toolbars;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JToolBar;

import fr.imag.ufrima.ctte.ImagCTTE;
import fr.imag.ufrima.ctte.enums.EditorModes;
import fr.imag.ufrima.ctte.enums.OperatorTypes;

public class DiagramEditorInputsToolBar extends JToolBar {
	private ImagCTTE imagCTTE;
	/**
	 * Constructor
	 */
	public DiagramEditorInputsToolBar(ImagCTTE imagCTTE){
		this.imagCTTE = imagCTTE;
		InitComponents();
	}
	/**
	 * Initialize components
	 */
	protected void InitComponents(){
		tglbArrow = new javax.swing.JToggleButton();
        tglbAbstractionTask = new javax.swing.JToggleButton(); 
        tglbUserTask = new javax.swing.JToggleButton(); 
        tglbApplicationTask = new javax.swing.JToggleButton(); 
        tglbInteractionTask = new javax.swing.JToggleButton(); 
        tglbChoice = new javax.swing.JToggleButton();
        tglbOrderIndependency = new javax.swing.JToggleButton();
        tglbConcurrent = new javax.swing.JToggleButton();
        tglbConcurrentInfoExchange = new javax.swing.JToggleButton();
        tglbCTTDisabling = new javax.swing.JToggleButton();
        tglbSuspend = new javax.swing.JToggleButton();
        tglbEnabling = new javax.swing.JToggleButton();
        tglbEnablingInfoExchange = new javax.swing.JToggleButton();                      
        buttonGroup1 = new javax.swing.ButtonGroup(); 
        
     // diagram toolbar        
        tglbArrow.setFocusable(false);
        tglbArrow.setSelected(true);
        tglbArrow.setToolTipText("Selection");
        tglbArrow.setIcon(new javax.swing.ImageIcon("images\\SelectArrow.gif"));
        tglbArrow.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.NONE);
        	}
        });
        this.add(tglbArrow);        
        this.add(new javax.swing.JToolBar.Separator());

        tglbAbstractionTask.setFocusable(false);
        tglbAbstractionTask.setToolTipText("Abstraction Task");
        tglbAbstractionTask.setIcon(new javax.swing.ImageIcon("images\\abstractionico.gif"));
        tglbAbstractionTask.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_TASK);
        	}
        });
        this.add(tglbAbstractionTask);
        
        tglbUserTask.setFocusable(false);   
        tglbUserTask.setEnabled(false);
        tglbUserTask.setToolTipText("User Task");
        tglbUserTask.setIcon(new javax.swing.ImageIcon("images\\userico.gif"));
        tglbUserTask.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_TASK);
        	}
        });
        this.add(tglbUserTask);        
        
        tglbApplicationTask.setFocusable(false);
        tglbApplicationTask.setEnabled(false);
        tglbApplicationTask.setToolTipText("Application Task");
        tglbApplicationTask.setIcon(new javax.swing.ImageIcon("images\\applicationico.gif"));
        tglbApplicationTask.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_TASK);
        	}
        });
        this.add(tglbApplicationTask);
        
        tglbInteractionTask.setFocusable(false);
        tglbInteractionTask.setEnabled(false);
        tglbInteractionTask.setToolTipText("Interraction Task");
        tglbInteractionTask.setIcon(new javax.swing.ImageIcon("images\\interactionico.gif"));
        tglbInteractionTask.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_TASK);
        	}
        });
        this.add(tglbInteractionTask);
        
        this.add(new javax.swing.JToolBar.Separator());
                
        tglbChoice.setFocusable(false);     
        tglbChoice.setToolTipText("Choice");
        tglbChoice.setIcon(new javax.swing.ImageIcon("images\\choice.gif"));
        tglbChoice.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_OPERATOR, OperatorTypes.CHOICE);
        	}
        });

        this.add(tglbChoice);
        tglbOrderIndependency.setFocusable(false);
        tglbOrderIndependency.setToolTipText("Order Independency");
        tglbOrderIndependency.setIcon(new javax.swing.ImageIcon("images\\order.gif"));
        tglbOrderIndependency.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_OPERATOR, OperatorTypes.ORDER_INDEPENDENCY);
        	}
        });
        this.add(tglbOrderIndependency);
        tglbConcurrent.setFocusable(false);
        tglbConcurrent.setToolTipText("Concurrent");
        tglbConcurrent.setIcon(new javax.swing.ImageIcon("images\\interleave.gif"));
        tglbConcurrent.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_OPERATOR, OperatorTypes.CONCURRENT);
        	}
        });
        this.add(tglbConcurrent);
        tglbConcurrentInfoExchange.setFocusable(false);
        tglbConcurrentInfoExchange.setToolTipText("Concurrent with info exchange");
        tglbConcurrentInfoExchange.setIcon(new javax.swing.ImageIcon("images\\sincro.gif"));
        tglbConcurrentInfoExchange.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_OPERATOR, OperatorTypes.CONCURRENT_WITH_INFO_EXCHANGE);
        	}
        });
        this.add(tglbConcurrentInfoExchange);
        tglbCTTDisabling.setFocusable(false);
        tglbCTTDisabling.setToolTipText("CTT Disabling");
        tglbCTTDisabling.setIcon(new javax.swing.ImageIcon("images\\disabling.gif"));
        tglbCTTDisabling.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_OPERATOR, OperatorTypes.CTT_DISABLING);
        	}
        });
        this.add(tglbCTTDisabling);
        tglbSuspend.setFocusable(false);    
        tglbSuspend.setToolTipText("Suspend/Resume");
        tglbSuspend.setIcon(new javax.swing.ImageIcon("images\\suspend.gif"));
        tglbSuspend.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_OPERATOR, OperatorTypes.SUSPEND_RESUME);
        	}
        });
        this.add(tglbSuspend);
        tglbEnabling.setFocusable(false);   
        tglbEnabling.setToolTipText("Enabling");
        tglbEnabling.setIcon(new javax.swing.ImageIcon("images\\enabling.gif"));
        tglbEnabling.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_OPERATOR, OperatorTypes.ENABLING);
        	}
        });
        this.add(tglbEnabling);
        tglbEnablingInfoExchange.setFocusable(false);
        tglbEnablingInfoExchange.setToolTipText("Enabling with info exchange");
        tglbEnablingInfoExchange.setIcon(new javax.swing.ImageIcon("images\\enablinginfo.gif"));
        tglbEnablingInfoExchange.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent arg0) {
        		imagCTTE.getCurrentTaskDiagram().setEditorModes(EditorModes.INSERING_OPERATOR, OperatorTypes.ENABLING_WITH_INFO_EXCHANGE);
        	}
        });
        this.add(tglbEnablingInfoExchange);                                   
                
        buttonGroup1.add(tglbArrow);
        buttonGroup1.add(tglbAbstractionTask);
        buttonGroup1.add(tglbUserTask);
        buttonGroup1.add(tglbApplicationTask);
        buttonGroup1.add(tglbInteractionTask);
        buttonGroup1.add(tglbChoice);
        buttonGroup1.add(tglbOrderIndependency);
        buttonGroup1.add(tglbConcurrent);
        buttonGroup1.add(tglbConcurrentInfoExchange);
        buttonGroup1.add(tglbCTTDisabling);
        buttonGroup1.add(tglbSuspend);
        buttonGroup1.add(tglbEnabling);
        buttonGroup1.add(tglbEnablingInfoExchange);
	}
	/**
	 * Components
	 */
	private javax.swing.JToggleButton tglbArrow;
    private javax.swing.JToggleButton tglbAbstractionTask;
    private javax.swing.JToggleButton tglbUserTask;
    private javax.swing.JToggleButton tglbApplicationTask;
    private javax.swing.JToggleButton tglbInteractionTask;
    private javax.swing.JToggleButton tglbChoice;
    private javax.swing.JToggleButton tglbOrderIndependency;
    private javax.swing.JToggleButton tglbConcurrent;
    private javax.swing.JToggleButton tglbConcurrentInfoExchange;
    private javax.swing.JToggleButton tglbCTTDisabling;
    private javax.swing.JToggleButton tglbSuspend;
    private javax.swing.JToggleButton tglbEnabling;
    private javax.swing.JToggleButton tglbEnablingInfoExchange;
    
    private javax.swing.ButtonGroup buttonGroup1;
}
